<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  </style>
</head>

<body>
  <span id="second">5</span>
  <span>秒后跳转到百度，失败请手动点击<a href="https://www.baidu.com/">点击跳转</a></span>
  <script>
    //定时跳转
    function goto(url) {
      var _second = document.getElementById('second');
      var _num = +_second.innerHTML;
      if (_num <= 0) {
        location.href = url;
        return;
      }
      _second.innerHTML = --_num;
      setTimeout(function () {
        goto(url);
      }, 1000)
    }
    setTimeout(function () {
      goto("https://www.baidu.com/");
    }, 1000)


  </script>
</body>

</html>